package com.j1903.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@Slf4j
public class AutoFill implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        //(指定被填充字段名,填充的值,metaObject对象)
        this.setFieldValByName("createdDate",new Date(),metaObject);
        this.setFieldValByName("updatedDate",new Date(),metaObject);

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updatedDate",new Date(),metaObject);

    }
}
